package com.znjc.device.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.znjc.common.annotation.Excel;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 【请填写功能名称】对象 device_command
 *
 * @author zengpc
 * @date 2023-12-04
 */
@Data
public class DeviceCommand extends BaseZnjcEntity {
    private static final long serialVersionUID = 1L;


    /**
     * 规则名称
     */
    @Excel(name = "规则名称")
    private String name;

    /**
     * 命令指令
     */
    @Excel(name = "命令指令")
    private String command;

    /**
     * 命令类别 数据字典 command_type 0设置命令
     */
    @Excel(name = "命令类别")
    private String commandType;

    /**
     * 开始读取数据位置
     */
    @Excel(name = "开始读取数据位置")
    private Integer dataStartBit;

    /**
     * 数据分割位数
     */
    @Excel(name = "数据分割位数")
    private Integer dataSplitLen;

    /**
     * 数据类别：数据字典 data_type
     */
    @Excel(name = "数据类别")
    private String dataType;

    /**
     * 数据所在位数
     */
    @Excel(name = "数据所在位数")
    private Integer dataBit;

    /**
     * 数据对比值
     */
    @Excel(name = "数据对比值")
    private String dataJudgment;

    /**
     * 顺序号
     */
    @Excel(name = "顺序号")
    private Integer orderByNum;

    /**
     * 是否存在此串口标识 默认不存在
     */
    @TableField(exist = false)
    private boolean flag = false;

    public boolean isAdmin() {
        return isAdmin(this.getId());
    }

    public static boolean isAdmin(Long id) {
        return id != null && 1L == id;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("name", getName())
                .append("command", getCommand())
                .append("commandType", getCommandType())
                .append("dataStartBit", getDataStartBit())
                .append("dataSplitLen", getDataSplitLen())
                .append("dataType", getDataType())
                .append("dataBit", getDataBit())
                .append("dataJudgment", getDataJudgment())
                .append("orderByNum", getOrderByNum())
                .append("status", getStatus())
                .append("delFlag", getDelFlag())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("deptId", getDeptId())
                .append("remark", getRemark())
                .toString();
    }
}
